package com.pro.controller;

import com.pro.pojo.JsUserOrder;
import com.pro.pojo.JsonData;
import com.pro.service.JsUserReturnPendingService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * ClassName:JsUserReturnGoodsController
 * Package:com.pro.controller
 * Description: 退货待处理列表
 *
 * @Date:2021/11/11 下午 8:58
 * @Author: WYH
 */
@Controller
@RequestMapping("/returnPen")
public class JsUserReturnPendingController {

    @Autowired
    private JsUserReturnPendingService jsUserReturnPendingService;
    /**
     * @author WYH
     * @date 2021/11/12 下午 7:03
     * @content : 查询退货待处理列表
     */
    @RequestMapping("/getAllReGoo")
    @ResponseBody
    public JsonData getAllReGoo(String orderPaymentChannel, String orderSource) {
        orderPaymentChannel = orderPaymentChannel  != null  ? "%"+orderPaymentChannel+"%":"%%";
        orderSource = orderSource = orderSource != null ? "%"+orderSource+"%":"%%";
        List<JsUserOrder> allCourse = jsUserReturnPendingService.getAllReGoo(orderPaymentChannel, orderSource);
        int count = jsUserReturnPendingService.count(orderPaymentChannel, orderSource);
        return allCourse != null ? JsonData.buildSuccess(allCourse,count):JsonData.buildError("服务端错误");
    }

    /**
     * @author WYH
     * @date 2021/11/12 下午 7:03
     * @content : 删除选中数据
     */
    @RequestMapping("/delReGoo")
    @ResponseBody
    public JsonData delReGoo(Integer orderId) {
        Boolean aBoolean = jsUserReturnPendingService.delReGoo(orderId);
        return aBoolean!= false ? JsonData.buildSuccess(aBoolean):JsonData.buildError("服务端错误");
    }
}
